'''
Created on Sep 17, 2012

@author: Jason
'''
import os
import binascii

from Crypto.Hash import SHA256

def solve():
    fileName = 'test.mp4'
    blockSize = 1024
    size = os.path.getsize(fileName)
    
    endBlock = size // blockSize;
    if(size % blockSize == 0):
        endBlock -= 1
        
    f = open(fileName, 'rb')
    
    
    hashCode = b''
    
    while endBlock >= 0:
        f.seek(endBlock * blockSize, 0)
        endBlock -= 1
        block = f.read(blockSize)
        block = block + hashCode
        sha = SHA256.new()
        sha.update(block)
        hashCode = sha.digest()

    print(binascii.hexlify(hashCode))
    f.close()
    

if __name__ == '__main__':
    solve()